﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StyleMVVM.Validation.Impl.Method
{
	public class SyncValidationMethodRule<T> : BaseMethodRule<T>, ISyncValidationRule
	{
		private readonly Action<IRuleExecutionContext<T>> action;

		public SyncValidationMethodRule(Action<IRuleExecutionContext<T>> action,
		                                string name,
		                                IEnumerable<string> standards,
		                                IEnumerable<string> dependentProperties) : base(name, standards, dependentProperties)
		{
			this.action = action;
		}

		public void Validate(IRuleExecutionContext context)
		{
			IRuleExecutionContext<T> ruleExecutionContext = new RuleExecutionContext<T>(context);

			action(ruleExecutionContext);
		}
	}
}